package com.teach.javafxclient.controller.base;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;

/**
 * @author Liang Jianlin
 * @date 2024-04-30 02:04
 */
public class AnnouncementItemController {
    public String announcementId;
    @FXML
    public ImageView pinIt;
    @FXML
    public ImageView deletePin;
    private boolean isSeen;
    @FXML
    public AnchorPane header;
    @FXML
    public Label title;
    @FXML
    public Label time;
    @FXML
    public Text content;
    @FXML
    public AnchorPane contentContainer;
    @FXML
    public ImageView icon;
    @FXML
    public VBox mainPage;

    public void initialize(){
        contentContainer.setVisible(false);
        contentContainer.setManaged(false);
        mainPage.setOnMouseClicked(e->{
            isSeen = !isSeen;
            contentContainer.setVisible(isSeen);
            contentContainer.setManaged(isSeen);
        });

    }
    public void setItem(String noticeTitle,String noticeContent,String sendTime,Boolean noticePinned,String id){
        title.setText(noticeTitle);
        time.setText(sendTime);
        content.setText(noticeContent);
        announcementId = id;
        if(noticePinned){
            header.setStyle("-fx-background-color:#30336b");
            pinIt.setManaged(false);
            pinIt.setVisible(false);
            deletePin.setVisible(true);
            deletePin.setManaged(true);
            icon.setManaged(true);
            icon.setVisible(true);
        }else{
            header.setStyle("-fx-background-color:#6C5CE7");
            deletePin.setVisible(false);
            deletePin.setManaged(false);
            icon.setManaged(false);
            icon.setVisible(false);
            pinIt.setManaged(true);
            pinIt.setVisible(true);
        }
    }
}
